package com.zdp.strategy.handler.oss;

import cn.hutool.core.util.EnumUtil;
import com.zdp.common.enums.ChannelType;
import com.zdp.strategy.entity.req.OssChannelReq;
import com.zdp.strategy.entity.resp.OssChannelResp;
import com.zdp.strategy.handler.AbstractChannelStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AlibabaOssChannelStrategyHandler extends AbstractChannelStrategy<OssChannelReq, OssChannelResp> {

    @Override
    public boolean apply(ChannelType channelType) {
        return EnumUtil.equals(ChannelType.ALIBABA, channelType.getCode());
    }

    @Override
    protected OssChannelResp mock() {
        OssChannelResp resp = new OssChannelResp();
        resp.setFileUrl("http://www.alibaba.resource/1.jpg");
        return resp;
    }

    @Override
    protected void setChannelConfig(String channelConfig) {
        log.info("设置渠道配置:{}", channelConfig);
    }

    @Override
    protected OssChannelResp doInvoke(OssChannelReq ossChannelReq) {
        log.info("OssChannelReq ---> alibaba oss 服务请求对象");
        log.info("请求alibaba oss 服务接口");
        log.info("获得alibaba oss 服务相应");
        OssChannelResp resp = new OssChannelResp();
        resp.setFileUrl("http://www.alibaba.resource/2.jpg");
        return resp;
    }
}
